home *** CD-ROM | disk | FTP | other *** search
- Path: library.erc.clarkson.edu!rpi!not-for-mail
- From: Senthil <senthil@genmagic.com>
- Newsgroups: comp.lang.c++.moderated,comp.lang.c++
- Subject: Re: Meaning of the specifier volatile?
- Date: 3 Jan 1996 09:28:27 -0000
- Organization: GENERAL MAGIC
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: kanze@gabi-soft.fr
- Message-ID: <4cdi7r$ci9@netlab.cs.rpi.edu>
- References: <4c9740$27n@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
-
- X-Original-Date: Tue, 02 Jan 1996 15:25:49 -0800
-
- Srinivas Vobilisetti wrote:
- >
- > X-Original-Date: 31 Dec 1995 01:42:27 GMT
- >
- > Hello,
- >
-
- Concept of volatile can be easily using a simple example:
-
- int a
-
- a = 1;
- a++
- if (a==1) {
- ...
- }
-
- typically compiler loads the value of variable a, into a register of a processor
- before executing 'a++'. and compares the value of register that holds the value
- instead of checking the value at the actual memory location. This optimization is default
- in any C compiler. If suppose the location of variable a is a hardware location like
- printer port, this optimization won't work, to supress such optimization we add the keyword
- volatile, In that case compiler generate instruction to fetch from actual location instead
- of fetching value from register.
-
-
-
- > I referred to various books on C++ including The C++ Programming Language
- > -Bjarne Stroustrup, C++ Primer -Stanley Lipmann, etc. Nowhere i could find
- > exact meaning of the specifier volatile. Thanks in advance for your help. I
- > would appreciate the reply at my email address srv@cs.wayne.edu
- >
- > Thanks
- > Srinivas
- > srv@cs.wayne.edu
-
- [ comp.lang.c++.moderated is a moderated newsgroup. Submit articles ]
- [ to <c++-submit@netlab.cs.rpi.edu>. The moderation policy can be ]
- [ retrieved from <http://netlab.cs.rpi.edu/~cppmods/guide.html>. ]
- [ Moderators can be reached at: c++-request@netlab.cs.rpi.edu. ]
-